__author__ = 'East'

# *args：接受N个位置参数，转换成元组的形式
def test(*args):
    print(args)


test(1, 2, 3, 4, 5)

test(*[1, 2, 3, 4, 5])      # args = tuple([1, 2, 3, 4, 5])

def test1(x, *args):
    print(x)
    print(args)

test1(1, 2, 3, 4, 5, 6, 7)

# 接受字典  **kwargs: 把n个关键字参数转换成字典的方式
def test2(**kwargs):
    print(kwargs)
    print(kwargs['name'])

test2(name='alex', age=8, sex = 'F')
test2(**{'name': 'alex', 'age': 8})


def test3(name, **kwargs):
    print(name)
    print(kwargs)

test3('alex')
test3('alex', age = 18, sex='m')

def test4(name, age = 18, **kwargs):
    print(name)
    print(age)
    print(kwargs)
    logger('TEXT4')

def logger(source):
    print('from %s' % source)

test4('alex', sex = 'm', hobby = 'tesla')
test4('alex', age = 3,  sex = 'm', hobby = 'tesla')

test4('alex', 5, sex = 'm', hobby = 'tesla')